package com.mall.server.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.commons.utils.PageUtils;
import com.mall.dubbo.api.PmsBrandApi;
import com.mall.dubbo.api.SmsHomeBrandApi;
import com.tanhua.model.domain.*;
import com.tanhua.model.vo.PageVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HomeService {

    @DubboReference
    private SmsHomeBrandApi smsHomeBrandApi;


    /**
     * 分页查询推荐品牌
     * @param brandName
     * @param recommendStatus
     * @param page
     * @return
     */
    public PageVo brandList(String brandName, Integer recommendStatus, Page<SmsHomeBrand> page) {
        page =smsHomeBrandApi.brandList(brandName,recommendStatus,page);
        return PageUtils.getPageVo(page);
    }

    /**
     * 批量修改推荐品牌状态
     * @param ids
     * @param recommendStatus
     * @return
     */
    public void updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
        smsHomeBrandApi.updateRecommendStatus(ids,recommendStatus);
    }


    /**
     * 修改推荐品牌排序
     * @param smsHomeBrand
     * @return
     */
    public void updateSort(SmsHomeBrand smsHomeBrand) {
        smsHomeBrandApi.updateSort(smsHomeBrand);
    }

    /**
     * 添加首页推荐品牌
     * @param smsHomeBrand
     * @return
     */
    public void create(List<SmsHomeBrand> smsHomeBrand) {
        smsHomeBrandApi.create(smsHomeBrand);
    }

    /**
     * 批量删除推荐品牌
     * @param ids
     * @return
     */
    public void delete(List<Integer> ids) {
        smsHomeBrandApi.delete(ids);
    }






    //============================================新品推荐
    /**
     * 分页查询首页新品
     * @param productName
     * @param recommendStatus
     * @param page
     * @return
     */
    public PageVo newProductList(String productName, Integer recommendStatus, Page<SmsHomeNewProduct> page) {
        Page resultPage = smsHomeBrandApi.newProductList(productName,recommendStatus,page);
        return PageUtils.getPageVo(resultPage);
    }

    /**
     *  添加首页新品
     * @param smsHomeNewProduct
     * @return
     */
    public void createNewProduct( List<SmsHomeNewProduct> smsHomeNewProduct) {
        smsHomeBrandApi.createNewProduct(smsHomeNewProduct);
    }


    /**
     * 批量删除首页新品
     * @param ids
     * @return
     */
    public void deleteNewProduct(List<Integer> ids) {
        smsHomeBrandApi.deleteNewProduct(ids);
    }

    /**
     * 批量修改首页新品状态   是否推荐
     * @param ids
     * @param recommendStatus
     * @return
     */
    public void updateNewProductRecommendStatus(List<Long> ids, Integer recommendStatus) {
        smsHomeBrandApi.updateNewProductRecommendStatus(ids,recommendStatus);
    }

    /**
     * 修改首页新品排序
     * @param smsHomeNewProduct
     * @return
     */
    public void updateNewProductSort(SmsHomeNewProduct smsHomeNewProduct) {
        smsHomeBrandApi.updateNewProductSort(smsHomeNewProduct);
    }


    //============================================人气推荐
    /**
     * 分页查询推荐
     * @param productName
     * @param recommendStatus
     * @param page
     * @return
     */
    public PageVo recommendProductList(String productName, Integer recommendStatus, Page<SmsHomeRecommendProduct> page) {
        Page resultPage =smsHomeBrandApi.recommendProductList(productName,recommendStatus,page);
        return  PageUtils.getPageVo(resultPage);
    }


    /**
     * 添加人气推荐
     * @param smsHomeRecommendProduct
     * @return
     */
    public void createRecommendProduct(List<SmsHomeRecommendProduct> smsHomeRecommendProduct) {
        smsHomeBrandApi.createRecommendProduct(smsHomeRecommendProduct);
    }

    /**
     * 批量删除人气推荐
     * @param ids
     * @return
     */
    public void deleteRecommendProduct(List<Integer> ids) {
        smsHomeBrandApi.deleteRecommendProduct(ids);
    }

    /**
     * 批量修改人气推荐   是否推荐
     * @param ids
     * @param recommendStatus
     * @return
     */
    public void updateRecommendProductRecommendStatus(List<Long> ids, Integer recommendStatus) {
        smsHomeBrandApi.updateRecommendProductRecommendStatus(ids,recommendStatus);
    }

    /**
     * 修改人气排序
     * @param smsHomeRecommendProduct
     * @return
     */
    public void updateRecommendProductSort(SmsHomeRecommendProduct smsHomeRecommendProduct) {
        smsHomeBrandApi.updateRecommendProductSort(smsHomeRecommendProduct);
    }



    //============================================专题推荐

    /**
     * 分页查询专题推荐
     * @param subjectName
     * @param recommendStatus
     * @param page
     * @return
     */
    public PageVo recommendSubjectList(String subjectName, Integer recommendStatus, Page<SmsHomeRecommendSubject> page) {
        Page resultPage =smsHomeBrandApi.recommendSubjectList(subjectName,recommendStatus,page);
        return PageUtils.getPageVo(resultPage);
    }


    /**
     * 添加首页推荐专题
     * @param smsHomeRecommendSubject
     */
    public void recommendSubjectCreate(List<SmsHomeRecommendSubject> smsHomeRecommendSubject) {
        smsHomeBrandApi.recommendSubjectCreate(smsHomeRecommendSubject);
    }

    /**
     * 批量删除专题推荐
     * @param ids
     * @return
     */
    public void deleteRecommendSubject(List<Integer> ids) {
        smsHomeBrandApi.deleteRecommendSubject(ids);
    }

    /**
     * 批量修改专题推荐   是否推荐
     * @param ids
     * @param recommendStatus
     * @return
     */
    public void updateRecommendSubjectRecommendStatus(List<Long> ids, Integer recommendStatus) {
        smsHomeBrandApi.updateRecommendSubjectRecommendStatus(ids,recommendStatus);
    }

    /**
     * 修改专题推荐排序
     * @param smsHomeRecommendSubject
     * @return
     */
    public void updateRecommendSubjectSort(SmsHomeRecommendSubject smsHomeRecommendSubject) {
        smsHomeBrandApi.updateRecommendSubjectSort(smsHomeRecommendSubject);
    }



//============================================广告列表
    /**
     *
     * @param endTime
     * @param type
     * @param name
     * @param page
     * @return
     */
    public PageVo advertiseList(String endTime, Integer type, String name, Page<SmsHomeAdvertise> page) {
        Page resultPage =smsHomeBrandApi.advertiseList(endTime,type,name,page);
        return PageUtils.getPageVo(resultPage);
    }


    /**
     * 添加广告
     * @param smsHomeAdvertise
     * @return
     */
    public void advertiseCreate(SmsHomeAdvertise smsHomeAdvertise) {
        smsHomeBrandApi.advertiseCreate(smsHomeAdvertise);
    }

    /**
     * 批量删除广告
     * @param ids
     */
    public void deleteAdvertise(List<Integer> ids) {
        smsHomeBrandApi.deleteAdvertise(ids);
    }

    /**
     * 修改广告上下线状态
     * @param smsHomeAdvertise
     */
    public void updateAdvertiseStatus(SmsHomeAdvertise smsHomeAdvertise) {
        smsHomeBrandApi.updateAdvertiseStatus(smsHomeAdvertise);
    }

    /**
     * 修改广告
     * @param smsHomeAdvertise
     * @return
     */
    public void updateAdvertise(SmsHomeAdvertise smsHomeAdvertise) {
        smsHomeBrandApi.updateAdvertise(smsHomeAdvertise);
    }

    /**
     * 获取广告详情
     * @param id
     * @return
     */
    public SmsHomeAdvertise getAdvertiseById(Long id) {
        return smsHomeBrandApi.getAdvertiseById(id);
    }
}
